import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import { HTTP_SERVER_URL, getToken } from '../../app/app.contant';
import 'rxjs/add/operator/map';

@Injectable()
export class DetailService {
    constructor(private http: HttpClient) { }
    /** 获取申请*/
    getapplymateriallist(applyID) {
        return this.http.get(HTTP_SERVER_URL + 'home/law/material/getapplymateriallist?_d_='+new Date()+'&token='+getToken()+'&applyID='+applyID, { observe: 'response' })
            .map((resp) => resp.body['data'])
            .catch((error: any) => Observable.throw(error || 'Server error'));
    }

    /** 获取申请单详情 */
    getMaterialApprovalLog(taskID){
        return this.http.get(HTTP_SERVER_URL+"home/law/material/getapprovallog?_d_="+new Date()+"&token="+getToken()+"&taskID="+taskID+"&applyID=0", { observe: 'response' })
            .map((resp) => resp.body['data'])
            .catch((error:any) => Observable.throw(error || 'server error'));
    }
}